home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
prodpack.zip
/
DB4PPSRC.EXE
/
_HELPSYS.PRG
< prev
next >
Wrap
Text File
|
1993-05-26
|
15KB
|
529 lines
PROCEDURE _HelpSys
PARAMETERS pc_file, pc_name, pc_dbf, pl_keep
*---------------------------------------------------------------------------
* NAME
* _HelpSys
*
* DESCRIPTION
* Help System for MFFUHELP programs as well as for the extended form
* capabilities. Extended form help will be stored in a database called
* "Sys_Help". MFFUHELP help will be stored in the dBASE Home directory
* in a database called "MFFUHELP". Users may access the system by calling
* the procedure with their own help database name. The structure of the
* database required is as follows:
*
* Field Field Name Type Width Dec Index
* 1 HLP_FILE Character 10 N
* 2 HLP_TITLE Character 25 N
* 3 HLP_NAME Character 10 N
* 4 HLP_HEADNG Character 40 N
* 5 HLP_TEXT Memo 10 N
* 6 RELATED Character 3 Y
*
* In addition, three index tags need to exist:
*
* INDEX ON UPPER( hlp_file - hlp_name ) TAG File_Name
* INDEX ON UPPER( hlp_file ) TAG Uniq_File UNIQUE
* INDEX ON related TAG related
*
* SYNOPSIS
* DO _HelpSys WITH pc_file, pc_name, pc_dbf, pl_keep
*
* PARAMETERS
* pc_file: Name of form file in the case of form help, and
* the of the popup in the case of system help
* pc_name: Name of the field in the case of form help, and
* the number of the bar in the case of system help
* pc_dbf: Name of the database to be used by _HelpSys (MFFUHELP,
* Sys_Help, or an inputted name by the user)
* pl_keep: Keep help database open even if it wasn't open upon entry
*
* Note: The the program is not sensative to the case (upper or lower)
* of the parameters, nor the spacing between pc_file and pc_name
*
* EXAMPLE
* DO _HelpSys WITH "Client", "Address", "Sys_Help", .T.
* ** OR **
* DO _HelpSys WITH "MakeLook", "3", "MFFUHELP", .F.
*
*---------------------------------------------------------------------------
PRIVATE gc_file, gc_elev, gc_file, gc_name, gc_shaft, gn_menwith, gn_top, ;
lc_dbf, lc_dbfname, lc_hlp_aka, lc_msg_col, lc_border, ;
lc_sav_col, lc_title, lc_view, ll_cancel, ll_cat, ll_close, ;
ll_content, ll_curs, ll_exct, ll_flds, ll_near, ll_stats, ll_tlk, ;
ln_memo_w, ln_recno, lc_headng
PRIVATE gnLevel && Three values: EDIT:1,MOD:2,TOP:3
gnLevel = 1
PRIVATE gnMemo && Current line in help frame
gnMemo = 1
PRIVATE ef_ms01_0,ef_ms02_0,ef_ms03_0,ef_ms04_0,ef_ms05_0,;
ef_ms06_0,ef_ms07_0,ef_ms08_0,ef_ms09_0
STORE "" TO ef_ms01_0,ef_ms02_0,ef_ms03_0,ef_ms04_0,ef_ms05_0,;
ef_ms06_0,ef_ms07_0,ef_ms08_0,ef_ms09_0
PRIVATE ef_scr1_0,ef_scr2_0,ef_scr3_0,ef_scr4_0,ef_scr5_0,;
ef_scr6_0,ef_scr7_0,ef_scr8_0,ef_scr9_0
PRIVATE ti_text
ti_text = ""
PRIVATE nMemoLines
nMemoLines = 0
PRIVATE cPopDef
cPopDef = ""
PRIVATE gnBarSel
gnBarSel = -1
*------------------------------------------------------------
*-- Prevent calling the help system, while in the help system
*------------------------------------------------------------
IF TYPE( "pc_file" ) = "C" .AND. UPPER( pc_file ) $ 'DLGCONT,DLGEDIT,DLGHELP'
RETURN
ENDIF
ON KEY LABEL F1
ll_tlk = _TalkMode( .F. ) && Save Environment ...
PRIVATE lTrap, lEscape
lTrap = SET( "TRAP" ) = "ON"
SET TRAP OFF
lEscape = SET( "ESCAPE" ) = "ON"
SET ESCAPE OFF
*------------------------------------------------------------------
*-- Save the database environment, and shut down any view if active
*------------------------------------------------------------------
IF ISBLANK( SET( "VIEW" ) )
lc_hlp_aka = ALIAS()
lc_view = ""
ELSE
lc_view = SET( "VIEW" )
ln_recno = RECNO()
CLOSE DATABASES
ENDIF
ln_memo_w = SET( "MEMOWIDTH" )
ll_cat = SET( "CATALOG" ) = "ON"
ll_exct = SET( "EXACT" ) = "OFF"
ll_near = SET( "NEAR" ) = "OFF"
ll_flds = SET( "FIELDS" ) = "ON"
ll_stats = SET( "STATUS" ) = "ON"
*-----------------------
*-- Setup the scroll bar
*-----------------------
gc_shaft = CHR( 176 ) && Set Elevator characters
gc_elev = "-"
STORE gc_shaft TO ef_scr1_0, ef_scr2_0, ef_scr3_0, ef_scr4_0, ef_scr5_0, ;
ef_scr6_0, ef_scr7_0, ef_scr8_0, ef_scr9_0
*------------------------------------------------------------------
*-- If status is on set it off to prevent status bar updates during
*-- execution, and restore screen to hide that fact from user
*------------------------------------------------------------------
IF ll_stats
SAVE SCREEN TO _HelpSys
SET STATUS OFF
RESTORE SCREEN FROM _HelpSys
*-- If clock is active, refresh it
IF SET( "CLOCK" ) = "ON"
SET CLOCK ON
ENDIF
ENDIF
SET MEMOWIDTH TO 65
SET CATALOG OFF
SET EXACT ON
SET NEAR ON
SET FIELDS OFF
IF TYPE( "FXl_dev" ) = "U"
FXl_dev = .F.
ENDIF
IF TYPE( "pc_dbf" ) = "L" .OR. ;
( TYPE( "pc_dbf" ) = "C" .AND. ISBLANK( pc_dbf ) )
pc_dbf = "MFFUHELP"
ENDIF
STORE .F. TO ll_content, ll_close
*--------------------------------------------------------------------
*-- If no parameters are sent, dBASE will set their values to be
*-- logical "False" which will cause data type mismatches in the
*-- program. Therefore if the user has failed to send any or all the
*-- parameters, initialize them to be defaults
*--------------------------------------------------------------------
DO CASE
CASE TYPE( "pc_file" ) = "L"
STORE "" TO pc_file, pc_name
CASE TYPE( "pc_name" ) = "L"
pc_name = ""
ENDCASE
lc_dbf = UPPER( TRIM( pc_dbf ) )
gc_file = UPPER( TRIM( pc_file ) )
gc_name = UPPER( TRIM( pc_name ) )
lc_dbfname = IIF( lc_dbf = "MFFUHELP", ;
HOME() + "MFFUHELP", ;
lc_dbf ;
)
*------------------------------------
*-- If all necessary help files exist
*------------------------------------
ll_cancel = .F.
IF FILE( lc_dbfname + ".dbf" ) .AND. FILE( lc_dbfname + ".mdx" ) .AND. ;
FILE( lc_dbfname + ".dbt" )
DO _HeOpenDb
ELSE
*-------------------------------------------
*-- Try the home directory for the help file
*-------------------------------------------
lc_dbfname = HOME() + lc_dbfname
IF FILE( lc_dbfname + ".dbf" ) .AND. FILE( lc_dbfname + ".mdx" ) .AND. ;
FILE( lc_dbfname + ".dbt" )
DO _HeOpenDb
ELSE && Not all necessary files exist
DO _He_NoFil WITH lc_dbfname && Display appropriate error message
ll_cancel = .T. && Set don't do flag
ENDIF
ENDIF
IF .NOT. ll_cancel
*-------------------------------------------------------------------
*-- Position help database to desired help points, if no help points
*-- were given, or the help points were erroneous, activate popups
*-- which will allow the user to select the help he wants.
*-- _HelpMain is a contents of contents, _HelpHdr is a contents
*-- of topics from the same form or popup
*-------------------------------------------------------------------
IF .NOT. ISBLANK( gc_file )
IF .NOT. ISBLANK( gc_name )
SEEK gc_file + gc_name
DO CASE
*-- Case it doesn't exist but develop mode is on
CASE FXl_dev .AND. .NOT. FOUND()
*-- Create default title
lc_headng = [Help for: ] + _Proper( _StrTran( gc_file, "_", " " ) )
lc_title = [Help for: ] + _Proper( _StrTran( gc_name, "_", " " ) )
*-- Create new help record
APPEND BLANK
*-- replace fields with parameters
REPLACE hlp_file WITH gc_file, hlp_name WITH gc_name, ;
hlp_headng WITH lc_title, hlp_title WITH lc_headng
gnLevel = 1
*-- Case it doesn't exist and develop mode is off
CASE .NOT. FXl_dev .AND. .NOT. FOUND()
SEEK gc_file
IF TRIM( hlp_file ) <> gc_file && file doesn't exist
*-- Sys_help cannot go to main table of contents
IF lc_dbf <> "SYS_HELP"
STORE "" TO gc_file, gc_name
gnLevel = 3
ELSE
DO _Err_Box WITH [No help for form file: ] + gc_file
ll_cancel = .T.
ENDIF
ELSE
gc_name = ""
gnLevel = 2
ENDIF
OTHERWISE
gnLevel = 1
ENDCASE
ELSE && gc_name was blank
SEEK gc_file
IF TRIM( hlp_file ) = gc_file && file doesn't exist
gnLevel = 2
ELSE && gc_file was erroneous
IF lc_dbf <> "SYS_HELP"
gc_file = ""
gnLevel = 3
ELSE
DO _Err_Box WITH [No help for form file: ] + gc_file
ll_cancel = .T.
ENDIF
ENDIF
ENDIF && .NOT. ISBLANK( gc_name )
ELSE && gc_file was blank
IF lc_dbf <> "SYS_HELP"
gnLevel = 3
ELSE
DO _Err_Box WITH [No help for form file: ] + gc_file
ll_cancel = .T.
ENDIF
ENDIF && .NOT. ISBLANK( gc_file )
*---------------------------------
*-- Setup the dialog box variables
*---------------------------------
FXL_Cancel = .F.
FXL_NoChng = .F.
DECLARE DLGCONT[ 5 ]
DLGCONT[ 1 ] = 0
DLGCONT[ 2 ] = .F.
DLGCONT[ 3 ] = .F.
DLGCONT[ 4 ] = .T.
DLGCONT[ 5 ] = .F.
DECLARE DLGEDIT[ 5 ]
DLGEDIT[ 1 ] = SPACE( 25 )
DLGEDIT[ 2 ] = SPACE( 40 )
DLGEDIT[ 3 ] = .F.
DLGEDIT[ 4 ] = .T.
DLGEDIT[ 5 ] = .F.
DECLARE DLGHELP[ 6 ]
DLGHELP[ 1 ] = .F.
DLGHELP[ 2 ] = .F.
DLGHELP[ 3 ] = .F.
DLGHELP[ 4 ] = .F.
DLGHELP[ 5 ] = .F.
DLGHELP[ 6 ] = .F.
*------------------------------------------------------
*-- Loop between the help dialog boxes until FXL_Cancel
*------------------------------------------------------
DO WHILE .NOT. FXL_Cancel
DO CASE
CASE gnLevel = 1
gc_file = TRIM( hlp_file )
gc_name = hlp_name
ti_text = Hlp_Headng
gnMemo = 1
DO DlgSetHp
DO DlgHelp
CASE gnLevel = 2
gc_file = TRIM( hlp_file )
gc_name = ""
gnMemo = 1
gnBarSel = -1
DLGCONT[ 1 ] = 0
TI_TEXT = Hlp_Title
FXL_CANCEL = .F.
DO DlgCont
IF .NOT. FXL_CANCEL
IF gnBarSel > 0
GO TOP
SKIP gnBarSel - 1
SET KEY TO
gnMemo = 1
DO DlgSetHp
TI_TEXT = TRIM( hlp_headng )
gnLevel = 1
ENDIF
ENDIF
CASE gnLevel = 3
TI_TEXT = [Table of Contents]
gnMemo = 1
gnBarSel = -1
DLGCONT[ 1 ] = 0
gnMemo = 1
DO DlgCont
FXL_CANCEL = .F.
IF .NOT. FXL_CANCEL
IF gnBarSel > 0
GO TOP
SKIP gnBarSel - 1
SET ORDER TO File_Name
gnLevel = 2
ENDIF
ENDIF
ENDCASE
ENDDO
ENDIF && .NOT. ll_cancel
*----------------------
*-- Restore Environment
*----------------------
IF ll_close
USE
ENDIF
IF .NOT. ISBLANK( lc_view )
SET VIEW TO ( lc_view )
GO ln_recno
ELSE
IF .NOT. ISBLANK( lc_hlp_aka )
SELECT ( lc_hlp_aka )
ENDIF
ENDIF
IF ll_cat
SET CATALOG ON
ENDIF
IF ll_exct
SET EXACT OFF
ENDIF
IF ll_near
SET NEAR OFF
ENDIF
IF ll_flds
SET FIELDS ON
ENDIF
IF ll_stats
SET STATUS ON
RESTORE SCREEN FROM _HelpSys
RELEASE SCREEN _HelpSys
*-- If clock is active, refresh it
IF SET( "CLOCK" ) = "ON"
SET CLOCK ON
ENDIF
ENDIF
SET MEMOWIDTH TO ln_memo_w
IF lTrap
SET TRAP ON
ELSE
SET TRAP OFF
ENDIF
IF lEscape
SET ESCAPE ON
ELSE
SET ESCAPE OFF
ENDIF
IF _TalkMode( ll_tlk)
ENDIF
IF TYPE( "gc_hsave" ) = "C"
ON KEY LABEL F1 DO _HelpSys WITH &gc_hsave
ENDIF
RETURN
*-- EOP: _HelpSys WITH pc_file, gc_name, pc_dbf
PROCEDURE _HeOpenDb
*----------------------------------------------------------------------------
* NAME
* _HeOpenDb - Opens the help file using lc_DbfName
*
*----------------------------------------------------------------------------
*-- Open or select help file
IF SELECT( lc_dbf ) > 0
SELECT ( lc_dbf )
ELSE
DO _SetOnEr
SELECT SELECT()
USE ( lc_dbfname )
ON ERROR
IF .NOT. pl_keep && If not keep help file open flag
ll_close = .T. && set close flag
ENDIF
ENDIF
*-- If all necessary index tags exist
IF TYPE( "FXL_Error" ) <> "L" .AND. ;
TAGNO( "File_Name" ) > 0 .AND. TAGNO( "Uniq_File" ) > 0
SET ORDER TO File_Name && Set needed tag
ll_cancel = .F. && Clear don't do flag
ELSE && Tag or tags don't exist
IF TYPE( "FXL_Error" ) <> "L"
DO _Err_Box WITH [Help index file missing tags: ] + ;
TRIM( lc_dbf ) + ".MDX"
ELSE
RELEASE FXL_Error
ENDIF
ll_cancel = .T. && Set don't do flag
ENDIF
RETURN
*-- EOP: _HeOpenDb
PROCEDURE _He_NoFil
PARAMETER pc_dbfname
*---------------------------------------------------------------------------
* NAME
* _He_NoFil
*
* DESCRIPTION
* Displays appropriate error message depending on which help data files
* (.dbf, .dbt, or .mdx) are missing
*
* SYNOPSIS
* DO _He_NoFil WITH pc_dbfname
*
* PARAMETERS
* pc_dbfname: Name of help database to check
*
* EXAMPLE
* DO _He_NoFil WITH lc_dbfname
* ll_cancel = .T.
*
* LIMITATIONS
* None
*
* DEPENDENCIES
* Called By: _HelpSys
* Calls: Nothing
*
*---------------------------------------------------------------------------
DO CASE
*-- If database doesn't exist
CASE .NOT. FILE( pc_dbfname + ".dbf" )
DO _Err_Box WITH [File not found: ] + pc_dbfname + ".DBF"
*-- If memo file doesn't exist
CASE .NOT. FILE( pc_dbfname + ".dbt" )
DO _Err_Box WITH [File not found: ] + pc_dbfname + ".DBT"
*-- If production MDX file doesn't exist
OTHERWISE
DO _Err_Box WITH [File not found: ] + pc_dbfname + ".MDX"
ENDCASE
RETURN
*-- EOP: _He_NoFil WITH pc_dbfname
*'---------------------------------------------------------------------
*' $Log: $
*'---------------------------------------------------------------------